package model;

import org.lwjgl.util.vector.Vector3f;

/**
 * 
 * @author Jevgeni Krutov
 *
 */
public class BoundingBox {
	float minX, maxX, minY, maxY, minZ, maxZ;
	private float halfX, halfY, halfZ;
	Vector3f centerOffset;
	
	BoundingBox(float minX, float maxX, float minY, float maxY, float minZ, float maxZ) {
		this.minX = minX;
		this.maxX = maxX;
		this.minY = minY;
		this.maxY = maxY;
		this.minZ = minZ;
		this.maxZ = maxZ;
		
		halfX = Math.abs((maxX - minX) / 2f);
		halfY = Math.abs((maxY - minY) / 2f);
		halfZ = Math.abs((maxZ - minZ) / 2f);
		
		centerOffset = new Vector3f((minX + maxX) / 2f, (minY + maxY) / 2f, (minZ + maxZ) / 2f);
	}
	
	public float getHalfX() {
		return halfX;
	}
	public float getHalfY() {
		return halfY;
	}
	public float getHalfZ() {
		return halfZ;
	}
	
	public Vector3f getCenterOffset() {
		return centerOffset;
	}
	
	@Override
	public String toString() {
		return "x:" + minX +"|"+ maxX + "  y:" + minY +"|"+ maxY + "  z:" + minZ +"|"+ maxZ + "  half-x-y-z:" + halfX + "|" + halfY + "|" + halfZ;
	}
}
